home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / B_SESSIO.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  16KB  |  490 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                This module was written by Vince Perriello                */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Mail Session Initiator                     */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. extern int CallerSendSync (void);
  51. extern int CalledRecvSync (void);
  52.  
  53. void b_session (int was_initiator)
  54. {
  55.    int i;
  56.    ADDR tmp;
  57.  
  58.    CURRENT = DEFAULT;
  59.  
  60.    mail_finished = 0;
  61.  
  62.    (void) time (&etm);
  63.  
  64.    freq_accum.bytes = 0L;
  65.    freq_accum.files = 0;
  66.    freq_accum.time  = 0L;
  67.  
  68.    if (un_attended && fullscreen)
  69.       do_ready (MSG_TXT(M_READY_CONNECT));
  70.  
  71.    /* Remove the old .REQ and .RSP files */
  72.  
  73.    for (i = 0; i < 10; i++)
  74.       {
  75.       if (alias[i].Net == 0)
  76.          break;
  77.  
  78.       tmp = alias[i];
  79.  
  80.    /* For a point, massage the address to get the right .REQ filename */
  81.  
  82.       if (tmp.Point != 0)
  83.          {
  84.          tmp.Node  = tmp.Point;
  85.          tmp.Point = 0;
  86.          tmp.Net   = (pvtnet > 0) ? (unsigned int) pvtnet : 0;
  87.          }        
  88.  
  89.       (void) sprintf (junk, "%s%s.REQ", CURRENT.sc_Inbound, Hex_Addr_Str (&tmp));
  90.       (void) unlink (junk);
  91.  
  92.       (void) sprintf (junk, "%s.RSP", Hex_Addr_Str (&tmp));
  93.       (void) unlink (junk);
  94.       }
  95.  
  96.    tmp.Zone = 0;
  97.    tmp.Net = 0;
  98.    tmp.Node = 0;
  99.    tmp.Point = 0;
  100.    tmp.Domain = NULL;
  101.  
  102.    remote_capabilities = 0;
  103.  
  104.    my_capabilities = (no_zapzed) ? 0 : (ZED_ZAPPER | ZED_ZIPPER);
  105.    my_capabilities |= (no_dietifna) ? 0 : Y_DIETIFNA;
  106.    if ((janus_baud >= cur_baud.rate_value) || (janus_OK))
  107.       my_capabilities |= DOES_IANUS;
  108.  
  109.    (void) flag_file (SET_SESSION_FLAG, &called_addr, 0);
  110.    if (was_initiator)
  111.       {
  112.  
  113. /*
  114.  *    OUTBOUND -- meaning call was made by us.
  115.  */
  116.  
  117.       last_type (1, &remote_addr);
  118.  
  119.       if (Whack_CR () == 0)
  120.          {
  121.  
  122. retry_outbound:
  123.  
  124.          switch (i = CallerSendSync())
  125.             {
  126.             case 1:
  127.             FTSC_sender (0);
  128.             break;
  129.  
  130.             case 2:
  131.             if (YooHoo_Sender ())
  132.                {
  133.                if ((remote_capabilities & my_capabilities) == 0)
  134.                   {
  135.                   no_WaZOO_Session = 1;
  136.                   status_line (MSG_TXT(M_NO_COMMON_PROTO));
  137.                   goto retry_outbound;
  138.                   }
  139.                WaZOO (1);
  140.                }
  141.             break;
  142.  
  143.             default:
  144.             break;
  145.  
  146.             } /* end switch */
  147.          }
  148.  
  149.       }
  150.    else
  151.       {
  152.  
  153. /*
  154.  *    INBOUND -- meaning we were connected to by another system.
  155.  */
  156.  
  157. retry_inbound:
  158.  
  159.       b_init ();
  160.  
  161.       switch (i = CalledRecvSync())
  162.          {   
  163.          case 1:                                 /* ESCape or Timeout    */
  164.          if (CARRIER && !mail_only)
  165.             {
  166.             last_type (3, &tmp);
  167.             (void) flag_file (CLEAR_SESSION_FLAG, &called_addr, 0);
  168.             BBSexit ();
  169.             }
  170.          break;
  171.  
  172.          case 2:                                 /* FTSC Netmail Session */
  173.          if (CARRIER)
  174.             {
  175.             tmp.Zone = (unsigned int) -1000;
  176.             last_type (2, &tmp);
  177.             tmp.Zone = 0;
  178.             ++hist.mail_calls;
  179.             if (un_attended && fullscreen)
  180.                {
  181.                (void) sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
  182.                sb_move (history_hWnd, HIST_MAIL_ROW, HIST_COL);
  183.                sb_puts (history_BBS, junk);
  184.                sb_show ();
  185.                }
  186.            (void) FTSC_receiver (0);
  187.             }
  188.          break;
  189.  
  190.          case 3:                                 /* WaZOO Netmail Session*/
  191.          if (YooHoo_Receiver ())
  192.             {
  193.             if ((remote_capabilities & my_capabilities) == 0)
  194.                {
  195.                no_WaZOO_Session = 1;
  196.                status_line (MSG_TXT(M_NO_COMMON_PROTO));
  197.                goto retry_inbound;
  198.                }
  199.             last_type (1, &remote_addr);
  200.             ++hist.mail_calls;
  201.             if (un_attended && fullscreen)
  202.                {
  203.                (void) sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
  204.                sb_move (history_hWnd, HIST_MAIL_ROW, HIST_COL);
  205.                sb_puts (history_BBS, junk);
  206.                sb_show ();
  207.                }
  208.             WaZOO (0);                           /* do WaZOO!!!          */
  209.             }
  210.          break;
  211.  
  212.          default:
  213.          if ((i >= 5) && (i < (5 + num_ext_mail)))    /* See if ext mail */
  214.             {
  215.             if (CARRIER)
  216.                {
  217.                last_type (4, &tmp);
  218.                (void) flag_file (CLEAR_SESSION_FLAG, &called_addr, 0);
  219.                UUCPexit (lev_ext_mail[i-5]);
  220.                }
  221.             }
  222.          break;
  223.  
  224.          } /* end switch */
  225.  
  226.       } /* end